package m2;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

/**
 * 耗时消息
 *
 * @author 郭鲁政
 */
public class Prouder {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("192.168.64.140");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("admin");
        connectionFactory.setPassword("admin");
        Channel channel = connectionFactory.newConnection().createChannel();
        //创建队列
        /**
         * 1.队列名字
         * 2.是否是持久化队列
         * 3.是否是独占队列
         * 4.队列不使用时是否删除
         */
        channel.queueDeclare("test-1", false, false, false, null);
        while (true) {
            String s = new Scanner(System.in).nextLine();
/**
 * 交换机名字
 * 2.路由秘钥
 * 3.其他属性
 * 4.消息内容
 */
            channel.basicPublish("", "test-1", null, s.getBytes());
        }
    }
}
